<?php
$form = $this->beginWidget('PsActiveForm', array(
	'id' => 'ajustment-payable-item-form',
	'enableAjaxValidation' => false,
	'enableClientValidation' => true,
	'clientOptions' => array(
		'validationDelay' => 200,
		'inputContainer' => 'tr',
		'validateOnSubmit' => true,
		'validateOnChange' => false,
	)
		));
?>

<div id="addPayableItem" class="">
	<div class="grid_16">
		<div class="section">
			<div class="block">
				<h2>Adjustment for Existing Payable Item</h2>
				<div class="table-block">
					<table class="form-table">
						<tr>
							<th scope="row" width="200">
								<?php echo $form->labelEx($payableItem, 'payee_name'); ?>
							</th>
							<td>
								<?php echo $form->textField($payableItem, 'payee_name', array('size' => 30, 'readonly' => 'readonly')); ?>
								<button id="btnSelPayableItem" class="link-button with-icon" type="button">
									<img src="/images/icons/fugue/plus.png" /> 
									Select Existing Payable Item
								</button>
								<?php echo $form->hiddenField($payableItem, 'payee_party_id'); ?>
								<?php echo $form->error($payableItem, 'payee_party_id'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="200">
								<?php echo $form->labelEx($payableItem, 'case_number', array('label' => 'Transaction #')); ?>
							</th>
							<td>
								<?php echo $form->textField($payableItem, 'case_number', array('size' => 30, 'readonly' => 'readonly')); ?>
								<?php echo $form->hiddenField($payableItem, 'property_case_id'); ?>
								<?php echo $form->hiddenField($payableItem, 'id'); ?>
								<?php echo $form->hiddenField($payableItem, 'comm_type'); ?>
								<?php echo $form->error($payableItem, 'property_case_id'); ?>
								<?php echo CHtml::hiddenField('type', $type); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="200">
								<?php echo $form->labelEx($payableItem, 'receipt_number', array('label' => 'Related Receipt #')); ?>
							</th>
							<td>
								<?php echo $form->textField($payableItem, 'receipt_number', array('size' => 30, 'readonly' => 'readonly')); ?>
								<?php echo $form->hiddenField($payableItem, 'payment_id'); ?>
								<?php echo $form->error($payableItem, 'payment_id'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="200">
								<?php echo $form->labelEx($payableItem, 'net_amount', array('label' => 'Adjustment Amount')); ?>
							</th>
							<td>
								<div class="form-table-block">
									<?php echo CHtml::label('Adjustment', 'adjustment', array('style' => 'text-align: center;')) ?>
									<?php
									$this->widget('common.widgets.PsAutoNumeric.PsAutoNumeric', array(
										'model' => $payableItem,
										'attribute' => 'net_amount',
										'value' => '',
										'htmlOptions' => array(
										),
										'options' => array(
											'vMin' => '-999999999.99',
											'aSign' => '$'
										)
									));
									
									?>
								</div>
								<div class="form-table-block">
									<?php echo CHtml::label('Current Amount', 'current-amount', array('style' => 'text-align: center;')) ?>
									+ <?php echo $form->textField($payableItem, 'net_amount_before', array('readonly' => 'readonly')); ?> 
								</div>
								<div class="form-table-block">
									<?php echo CHtml::label('Final Amount', 'final-amount', array('style' => 'text-align: center;')) ?>
									= <?php
									$this->widget('common.widgets.PsAutoNumeric.PsAutoNumeric', array(
										'model' => $payableItem,
										'attribute' => 'net_amount_total',
										'value' => '',
										'htmlOptions' => array(
										),
										'options' => array(
											'vMin' => '-999999999.99',
											'aSign' => '$'
										)
									));
									?>
								</div>

								<?php echo $form->error($payableItem, 'net_amount'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="200">
								<?php echo $form->labelEx($payableItem, 'description'); ?>
							</th>
							<td>
								<?php echo $form->textArea($payableItem, 'description'); ?>
								<?php echo $form->error($payableItem, 'description'); ?>
							</td>
						</tr>
						<tr id="auto-agency-row" style="display:none;">
							<th scope="row" width="200">
								Auto-adjust balance for company
							</th>
							<td>
								<input type="checkbox" name="auto_adjust_checkbox" />
							</td>
						</tr>
						
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="grid_16 relative">
	<button type="submit" class="link-button green no-margin with-icon" id="btnFinish">
		<span>Save</span>
	</button>
	&nbsp;or 
	<a class="link" 
	   href="<?php echo ($payableItem->id ? $this->createUrl('commissionPayable/view', array('id' => $payableItem->id)) : $this->createUrl('commissionPayable/index')); ?>">
		Cancel
	</a>
</div>
<?php $this->endWidget(); ?>